package viewcomponents;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JPanel;

import model.turtle.Turtle;
import controller.Controller;

import view.Observer;

/**
 * Class for catching command typing
 * Includes a textfield and a button
 * Either pressing "Enter" or clicking button can catch input string
 *
 */
public class CommandInput extends JPanel //implements Observer
{
	private SLogoInput myTextField;
	private Controller myController;
	private JButton myButton;
	
	public CommandInput(Controller controller)
	{
		myController = controller;
		
		myTextField = new SLogoInput();
		myButton = new JButton("Run!");
		myButton.addActionListener(new ActionListener()
				{
			       @Override
			       public void actionPerformed(ActionEvent arg0) {
				        myButton.setActionCommand("Run!");
				        myButton.addActionListener(myController);
				        myButton.setEnabled(true);
			        }
				});
		add(myTextField, BorderLayout.WEST);
		add(myButton, BorderLayout.EAST);
		setVisible(true);
	}
	
	public String getInput()
	{
		return myTextField.getInput();
	}

}
